<template>
  <!-- @click="$router.push('/article/' + article.art_id)
  :to="'/article/' + article.art_id"
  :to="`/article/'${article.art_id}`
  van-cell: vant 组件和 router-link 是一样的

  router-link 的用法: <router-link to="{ name: 'Article', params: { articleId: article.art_id } }"></router-link>
  -->
  <div class="article-item">
    <van-cell-group>
      <van-cell
        :to="{ name: 'Article', params: { articleId: article.art_id } }"
      >
        <div slot="title">{{ article.title }}</div>

        <div slot="label">
          <div v-if="article.cover.type === 3">
            <span v-for="(obj, ind) in article.cover.images" :key="ind">
              <van-image width="100" height="100" :src="obj" />
            </span>
          </div>
          <div>
            <span>{{ article.aut_name }} </span>
            <span>{{ article.comm_count }}评论 </span>
            <span>{{ article.pubdate | relativeTime }} </span>
          </div>
        </div>

        <div slot="default" v-if="article.cover.type === 1">
          <van-image width="100" height="100" :src="article.cover.images[0]" />
        </div>
      </van-cell>
    </van-cell-group>
  </div>
</template>

<script>
export default {
  name: 'ArticleItem',
  components: {},
  props: {
    // 定义一个props 接收这行数据
    article: {
      type: Object,
      required: true
    }
  },
  data () {
    return {}
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  methods: {}
}
</script>
<style lang="less" scoped>
.article-item {
  .title {
    font-size: 32px;
    color: #3a3a3a;
  }

  .van-cell__title {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .van-cell__value {
    flex: unset;
    width: 232px;
    height: 146px;
    padding-left: 25px;
  }

  .right-cover {
    width: 100%;
    height: 146px;
  }

  .label-info-wrap span {
    font-size: 22px;
    color: #b4b4b4;
    margin-right: 25px;
  }

  .cover-wrap {
    display: flex;
    padding: 30px 0;
    .cover-item {
      flex: 1;
      height: 146px;
      &:not(:last-child) {
        padding-right: 4px;
      }
      .cover-item-img {
        width: 100%;
        height: 146px;
      }
    }
  }
}
</style>
